package com.多线程07.demo08;

public class SellTicket implements Runnable {

    //准备票
    private int ticketCount = 100;


    public void run() {
        while (true){
            if (ticketCount<=0){
                break;
            }

            System.out.println(Thread.currentThread().getName()+"当前正在卖第"+ticketCount+"张票");

//            try {
//                Thread.sleep(100);
//            } catch (InterruptedException e) {
//                e.printStackTrace();
//            }

            ticketCount--;
        }
    }


    public static void main(String[] args) {
        SellTicket st = new SellTicket();
        Thread t1 = new Thread(st,"窗口1");
        Thread t2 = new Thread(st,"窗口2");
        Thread t3 = new Thread(st,"窗口3");

        t1.start();
        t2.start();
        t3.start();

    }


}
